<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld"%>
<%
String sortType=request.getParameter("conds.sortType");
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="pragma" content="no-cache" />
<title>欢迎访问信息产品运营互动中心！</title>
<link rel="stylesheet" href="<s:url value="/css/style.css"/>">
<style type="text/css">
	.mylink {
		FONT-SIZE: 9pt; COLOR: #0000FF; TEXT-DECORATION: none
    }
</style>
<script type="text/javascript" src="<s:url value="/xtreecheckbox/js/xtree.js"/>"></script>
<link type="text/css" rel="stylesheet" href="<s:url value="/xtreecheckbox/xtree.css"/>" />
<script type="text/javascript" src="<s:url value="/script/easyajax.js"/>"></script>
<script>
var sortType="<%=sortType%>";
var url="/poc/business/catalog/viewNextProductSort.action?conds.sortType="+sortType+"&conds.parentSort=";
var oldUrl="/poc/business/catalog/viewNextProductSort.action?conds.sortType="+sortType+"&conds.parentSort=";
var prodcutUrl="/poc/business/product/viewNextproductRefSort.action?conds.sort=";
function getNextView(url,obj,type){
    var path="/poc/images/arrow2.gif";
    var eventTr="";
	callSynchronized(url,function(XML){//同步调用
	    var ajax=new AjaxObj();
	    ajax.xml=XML.responseXML;
	    eventTr=obj.parentElement.parentElement;
	    //alert("id="+eventTr.id+" jb="+eventTr.jb+"  parentSort="+eventTr.parentSort+"   display"+eventTr.style.display);
	    var ind= eventTr.rowIndex+1;
	    var productCount=0;
	    for(i=0;i<ajax.length();i++){
	    	var tr=sortTable.insertRow(ind+i+productCount);
	    	var currentJb=parseInt(eventTr.jb)+1;
	    	tr.setAttribute("jb",currentJb);
	    	tr.setAttribute("parentSort",eventTr.id);
	    	var td=document.createElement("td");
	    	if(type!=1){
	    	    tr.setAttribute("id",eventTr.id+$$(ajax.datas(i),"id")+";");
	    	    tr.bgColor="F5FAFF";
		    	if($$(ajax.datas(i),"childCount")>0){
		    		td.innerHTML=getSpace(currentJb)+"<img id='img"+tr.id+"' onclick=showAndHidden(this);getNextView('"+oldUrl+$$(ajax.datas(i),"id")+"',this) src='"+path+"' height='12'>"+"&nbsp;"+$$(ajax.datas(i),"name");
		    	    tr.appendChild(td);
		    	    var productAjax=new AjaxObj();
		    	    productAjax.xml=ajax.datas(i);
		    	    productAjax.root="ProductRefSort";
		    	    for(n=0;n<productAjax.length();n++){
		    	        productCount++;
		    	    	var ptr=sortTable.insertRow(ind+i+productCount);
				    	var currentJbP=parseInt(eventTr.jb)+2;
				    	ptr.setAttribute("jb",currentJbP);
				    	ptr.setAttribute("parentSort",tr.id);//当前类型ID
				    	ptr.setAttribute("id",tr.id+"p"+$$(productAjax.datas(n),"id")+";");
				    	ptr.style.display="none";
				    	var ptd=document.createElement("td");
				    	var pathP="/poc/images/dot1.gif";
				    	ptd.innerHTML=getSpace(currentJbP)+"<img  src='"+pathP+"' height='12'>"+"&nbsp;<a href=\"/poc/business/product/showProduct.action?product.id="
			    			+$$(productAjax.datas(n),"product")+"\">"+$$(productAjax.datas(n),"productName")+"</a>";
					    ptr.appendChild(ptd);
		    	    }
		    	}else{
		    		td.innerHTML=getSpace(currentJb)+"<img  id='img"+tr.id+"' src='"+path+"' onclick=showAndHidden(this) height='12'>"+"&nbsp;"+$$(ajax.datas(i),"name");
		    	    tr.appendChild(td);
		    	    var productAjax=new AjaxObj();
		    	    productAjax.xml=ajax.datas(i);
		    	    productAjax.root="ProductRefSort";
		    	    for(n=0;n<productAjax.length();n++){
		    	        productCount++;
		    	    	var ptr=sortTable.insertRow(ind+i+productCount);
				    	var currentJbP=parseInt(eventTr.jb)+2;
				    	ptr.setAttribute("jb",currentJbP);
				    	ptr.setAttribute("parentSort",tr.id);//当前类型ID
				    	ptr.setAttribute("id",tr.id+"p"+$$(productAjax.datas(n),"id")+";");
				    	ptr.style.display="none";
				    	var ptd=document.createElement("td");
				    	var pathP="/poc/images/dot1.gif";
				    	ptd.innerHTML=getSpace(currentJbP)+"<img  src='"+pathP+"' height='12'>"+"&nbsp;<a href=\"/poc/business/product/showProduct.action?product.id="
			    			+$$(productAjax.datas(n),"product")+"\">"+$$(productAjax.datas(n),"productName")+"</a>";
					    ptr.appendChild(ptd);
		    	    }
		    	    
		    	}
	    	}else{//读取产品
	    	    path="/poc/images/dot1.gif";
	    	    tr.setAttribute("id",eventTr.id+"p"+$$(ajax.datas(i),"id")+";");
		    	td.innerHTML=getSpace(currentJb)+"<img  src='"+path+"' height='12'>"+"&nbsp;<a href=\"/poc/business/product/showProduct.action?product.id="
		    		+$$(ajax.datas(i),"product")+"\">"+$$(ajax.datas(i),"productName")+"</a>";
		       tr.appendChild(td);
	    	}
	    	
	    }
	});
	//if(type) return;
	path="/poc/images/arrow1_1.gif";
	if(eventTr.parentSort!=0){
		path="/poc/images/arrow2_1.gif";
	}
	obj.outerHTML="<img id='img"+eventTr.id+"'  onclick='showAndHidden(this)' src='"+path+"' height='12'>"+"&nbsp;";
	
}
function showAndHidden(obj){
	 var eventId=obj.parentElement.parentElement.id;
	 for(i=1;i<sortTable.rows.length;i++){
	 	var currentId=sortTable.rows[i].id;
	 	if(currentId.indexOf(eventId)==0&&currentId!=eventId){
	 		if(sortTable.rows[i].style.display==""){
	 			sortTable.rows[i].style.display="none";
	 		}else{
	 		    if(sortTable.rows[i].parentSort==eventId){
	 				sortTable.rows[i].style.display="";
	 				if(currentId.indexOf("p")==-1){
	 					document.getElementById("img"+sortTable.rows[i].id).src="/poc/images/arrow2.gif";
	 				}
	 			}
	 		
	 		}
	 		
	 	}
	 	
	 }
	 var path=obj.src;
	 path=path.substring(0,path.lastIndexOf("."));
	 if(path.indexOf("_1")==-1){
	 	path+="_1";
	 }else{
	 	path=path.substring(0,path.indexOf("_1"));
	 }
	 obj.src=path+".gif";
}
function getSpace(jb){
	var str="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	var returnStr="";
	while(jb>0){
		returnStr+=str;
		jb--;
	}
	return returnStr;
}
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<input style="display:none" type="button" onclick="test()" value="test"/>
<table width="998" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td  background="<s:url value="/images/home_4a.gif"/>"> 
      <table width="863" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
        <tr>
          <td width="197" valign="top">
		   <%@ include file="/commons/include/catalog_left.inc"%>  
   		  </td>
          <td valign="top" height="100%">
            
            <s:form id="form1" action="/business/catalog/productSort/listProductSort.action"
					method="post">
					<table width="660" border="0" cellspacing="0" cellpadding="0"
						background="<s:url value="/images/catalog_manage_8b.gif"/>">
						<tr>
							<td><img src="<s:url value="/images/catalog_manage_8.gif"/>" width=660
								height=11 alt=""></td>
						</tr>
						<tr>
							<td>
							<table id="sortTable" width="98%" border="0" cellspacing="0" cellpadding="7"
								align="center" class=tablecolor2>
								<tr>
									<td bgcolor="9AC2EB" width="13%">
									<div><font color="#FFFFFF">目录名称 </font></div>
									</td>
								</tr>
							<s:iterator value="productSorts" id="sort">
								<tr id=";<s:property value="id" />;" jb="0" parentSort="0" bgcolor="D4E7FA">
									<td>
										<img onclick="showAndHidden(this);getNextView(url+'<s:property value="id" />',this)" src="<s:url value="/images/arrow1.gif"/>" height="12">&nbsp;&nbsp;<s:property value="#sort.name" /><s:property value="id" />
									</td>
								</tr>
								<s:iterator value="productRefSorts">
									<tr style="display:none" id=";<s:property value="#sort.id" />;p<s:property value="id" />;" jb="0" parentSort=";<s:property value="#sort.id" />;" bgcolor="D4E7FA">
										<td>
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img  src='/poc/images/dot1.gif' height='12'>&nbsp;<s:property value="productName" /><s:property value="id" />
										</td>
								    </tr>
								</s:iterator>
							</s:iterator>
							</table>
							</td>
						</tr>
						<tr>
							<td>
								<img src="<s:url value="/images/catalog_manage_8a.gif"/>" width="660"
								height="9">
							</td>
						</tr>
					</table>
				</s:form> 
</body>
</html>
<script>

</script>